<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="http://ckfinder.com" prefix="ckfinder" %>
<%@ taglib uri="http://ckeditor.com" prefix="ckeditor" %>

<div class="block">
    
    <div class="block_head">
        <div class="bheadl"></div>
        <div class="bheadr"></div>
        
        <logic:lessThan name="saleForm" property="payID" value="1">
            <h2>Add Payment</h2>  
        </logic:lessThan>
        <logic:greaterThan name="saleForm" property="payID" value="0">
            <h2>Edit Payment</h2>  
        </logic:greaterThan> 
    </div>
    <!-- .block_head ends -->
    
    <div class="block_content clearfix">
        <html:form styleClass="validate-form" action="admin/sale.do" method="post">
            
            <logic:notEmpty name="errorMessages" >
                <div class="message errormsg">
                    <logic:iterate id="message" name="errorMessages">
                        <p><bean:write name="message"/></p>
                    </logic:iterate>
                </div>
            </logic:notEmpty>
            <logic:notEmpty name="successMessages" >
                <div class="message success">
                    <logic:iterate id="message" name="successMessages">
                        <p><bean:write name="message"/></p>
                    </logic:iterate>
                </div>
            </logic:notEmpty>
            <p>
                <label>Installment Payment: </label>
                <span class="text"><fmt:formatNumber type="CURRENCY" value="${saleForm.payment}"/></span>
            </p>
            <logic:lessThan name="saleForm" property="payID" value="1">
                <label>Amount Due: </label>
                <span class="text"><bean:write name="saleForm" property="amountDue"/></span>
            </logic:lessThan>
            <p>
                <html:hidden property="action" value="savePay"/>
                <html:hidden property="saleID" />
                <html:hidden property="payID" />
                <label for="amountPaid">Amount Paid:</label><span class="required">*</span><br/>
                <html:text styleId="amountPaid" styleClass="text small required number" property="amountPaid"/>
                <label for="amountPaid" class="note">U.S. dollars</label>
                <label for="amountPaid" class="error" generated="true" style="display:none;"></label>
            </p>
            <p>
                <label for="dueDate">Due Date:</label><span class="required">*</span><br/>
                <html:text styleId="dueDate" styleClass="text date_picker required dateISO" property="dueDate"/>
                <label for="dueDate" class="note">(yyyy-MM-dd)</label>
                <label for="dueDate" class="error" generated="true" style="display:none;"></label>
            </p>         
            
            <hr/>
            
            <p>
                <html:hidden property="action" value="savePermit"/>
                <html:submit property="method" value="Save" styleClass="submit small"/>
                <html:link action="/admin/sale.do" paramId="saleID" paramName="saleForm" paramProperty="saleID" styleClass="submit small gray">
                    Cancel
                </html:link>
            </p>
            
            
        </div>
        <!-- .block_content ends -->
    </html:form>
        
    <div class="bendl"></div>
    <div class="bendr"></div>
    
</div>
<!-- .block ends -->
